package stream;

import java.util.*;
import java.util.stream.Stream;

public class StreamTest2 {
    public static void main(String[] args) {
        // 如何获取List集合中的Stream流
        List<String> names = new ArrayList<>();
        Collections.addAll(names, "张无忌", "张三丰", "孙悟空", "牛魔王", "紫霞");
        Stream<String> stream = names.stream();

        // 如何获取Set集合中的Stream流
        HashSet<String> set = new HashSet<>();
        Collections.addAll(set, "张无忌", "张三丰", "刘德华", "高德地图", "紫霞");
        Stream<String> stream1 = set.stream();

        // 如何获取Map集合中的Stream流
        Map<String, Double> map = new HashMap<>();
        map.put("牛魔王", 175.4);
        map.put("至尊宝", 182.5);
        map.put("紫霞", 168.7);
        map.put("蜘蛛精", 165.4);

        Set<String> keys = map.keySet();
        Stream<String> ks = keys.stream();

        Collection<Double> values = map.values();
        Stream<Double> vs = values.stream();

        Set<Map.Entry<String, Double>> entries = map.entrySet();
        Stream<Map.Entry<String, Double>> stream2 = entries.stream();

        // 如何获取集合中的Stream流
        String[] names2 = {"鹤壁市", "安阳市", "郑州市", "洛阳市", "濮阳市"};
        Stream<String> s1 = Arrays.stream(names2);
        Stream<String> s2 = Stream.of(names2);
    }
}
